//
//  YDYSquareBtn.m
//  DYSisterAPP
//
//  Created by 杨德勇 on 16/7/31.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYSquareBtn.h"
#import <UIButton+WebCache.h>
@implementation YDYSquareBtn

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
    }
    
    return  self;
}

-(void)setSquareModel:(YDYMeSquareModel *)squareModel{
    _squareModel = squareModel;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.backgroundColor = [UIColor whiteColor];
    [self setTitle:squareModel.name forState:UIControlStateNormal];
    [self sd_setImageWithURL:[NSURL URLWithString:squareModel.icon] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];

}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    //设置图片大小
    self.imageView.ydy_y = self.ydy_height * 0.2;
    self.imageView.ydy_height = self.ydy_height * 0.5;
    self.imageView.ydy_width = self.imageView.ydy_height;
    self.imageView.ydy_centerX = self.ydy_width * 0.5;
    //设置label
    
    self.titleLabel.ydy_x = 0;
    self.titleLabel.ydy_y = self.imageView.ydy_bottom;
    self.titleLabel.ydy_width = self.ydy_width;
    self.titleLabel.ydy_height = self.ydy_height - self.titleLabel.ydy_y;
    
    
}
@end
